#ifndef __CANDATA_H__
#define __CANDATA_H__

#include "BasicInclude.h"
#include "UpdateData.h"

typedef struct
{
	CAN_RxHeaderTypeDef rxHeader;
	uint8_t rxData[8];
} CanRxFrame;

typedef enum
{
	eEmergyCmd = 0,
	eEmergyMsg,
	eWarningCmd,
	eWarningMsg,
	eRegularCmd,
	eRegularMsg,
	eTipCmd,
	eTipMsg
} eCanCmdLevel;

typedef __packed struct _CanCmdData
{
	eUpdateCmdSet eCmd;
	uint8_t u8CanData[8];
} CanCmdData;

typedef uint8_t (*CanCmdProcCallback)(void *data, uint8_t data_length);

#define MAKE_CANID(eCmdLvl,eCmd,u8ModelID)	((eCmdLvl << 8) | (eCmd << 3) | (u8ModelID & 0x07))


#define GETCMDBYCANID(CanID)	((CanID & 0xF8) >> 3)
#define GETMIDBYCANID(CanID)	(CanID & 0x07)

void InitCanData(void);

#endif
